package com.supercell.dao.impl;

import com.supercell.dao.DepartmentDAO;
import com.supercell.entity.Department;
import org.springframework.stereotype.Repository;

/**
 * Created by WUJO2 on 7/15/2016.
 */
@Repository
public class DepartmentDAOImpl extends GenericDAOImpl<Department> implements DepartmentDAO {
    @Override
    protected Class classOfT() {
        return Department.class;
    }

    @Override
    public void update(Department department) {
        Department oldRecord = get(department.getId());
        if (department.getDepartmentName() != null) {
            oldRecord.setDepartmentName(department.getDepartmentName());
        }
        if (department.getCity() != null) {
            oldRecord.setCity(department.getCity());
        }
        getSession().update(oldRecord);
    }
}
